from flask import Flask, render_template,abort

from flask_cors import CORS

app = Flask(__name__)
CORS(app)


def load_user(id):
    if id==1:
        return {'name':'ls'}
    else:
        return None


@app.route('/user/<id>')
def get_user(id):
    user = load_user(id)
    if not user:
        abort(404)
    return '<h1>Hello, %s</h1>' % user.name

@app.route('/')
def hello_world():
    return render_template("index.html")


@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


@app.errorhandler(500)
def internal_server_error(e):
    return render_template('500.html'), 500


@app.route('/createRoom')
def createRoom():
    pass


@app.route('/joinRoom')
def getRoomList():
    roomList = [1, 2, 23, 3, 4, 5]
    return render_template('joinRoom.html', roomList=roomList)


if __name__ == '__main__':
    app.run(host='192.168.3.14', debug=True)
